/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
/**
 *
 * $Id: TextTypes.hpp,v 1.2 2009-05-13 07:18:19 amaula Exp $
 *
 * \file
 * \brief MaCI - Text Interface Type definition header
 * \author Matthieu Myrsky <matthieu.myrsky@tkk.fi>
 *
 * 
 */
#ifndef _MACI_TEXT_TYPES_
#define _MACI_TEXT_TYPES_
#include <inttypes.h>
#include "timestamp.hpp"

namespace MaCI {

  /** MaCI - Text interface.
   *
   * This namespace contains all types, methods and helper classes
   * for implementing a Text interface for MaCI.
   */
  namespace Text {

    /** Text element types.
     * 
     * This enumeration defines the available elements for Text interface.
     *
     */
    enum ETextToSpeechType { 
      KTypeUnknown                    = -1, ///< Unknown type
      KTypeCommand                    = 0,  ///< Contains TCommand
      KTypeText                       = 1,  ///< Contains TText
      KTypeTextHeader                 = 2   ///< Contains TTextHeader
   

    };

    /** Text commands.
     *
     * Text commands for the 'TCommand' structure. Defined in global
     * 'Text' namespace because otherwise l^Husers would complain :)
     */
    enum ETextToSpeechCommand { 
      KCommandUnknown             = 0,  ///< Unkown command
      KCommandSendText            = 1,  ///< Send text command
      KCommandClearText           = 2,  ///< Clears text
      KReplyTextAccomplished      = 3   ///< Text accomplished e.g. text spoken,printed on screen
      
    };

    /**
     * Struct which contains text. 
     */
    struct TText
    {
      TText() :
        text(){}

      /**
       * Sets text
       * NOTE: max text length is 31 characters! 
       *
       * @param aText     Text to add 
       */
      void AddText(std::string aText)
      {
	memset(text, '\0', 32 );
	unsigned int length = aText.length();
      
        if(length >31){
          length = 31;
        }
	aText.copy(text,length);
      
      }
      char text[32];           ///< text
    };

    /**
     * Text header to define how many blocks of TText will be after this header
     *
     * @param aNumberOfTextBlock         Number of TText-structures after this header
     */
    struct TTextHeader
    {

      TTextHeader(unsigned int aNumberOfTextBlock)
        :number(aNumberOfTextBlock){}


      unsigned int number;
    };

    /**
     * Describes Commands for Text interface
     *
     */
    struct TCommand {
      TCommand(ETextToSpeechCommand aCmd = KCommandUnknown)
	: cmd(aCmd) {}
      
      uint32_t cmd; ///< Command \see ETextCommand
    };

    /**
     * Struct for storing information to send reply messages
     */
    struct TReplyInfo {
      TReplyInfo(int aSenderId = 0, int aMsgId= 0) :
	senderId(aSenderId),
	msgId(aMsgId){}
      
      int senderId;
      int msgId;
    };
  }
}

#endif ///<_MACI_TEXT_TO_SPEECH_TYPES_


